# -*- encoding: utf-8 -*-
from PyQt5.QtWidgets import QSplashScreen, QProgressBar
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import Qt, QBasicTimer
import time


class new_splashscreen(QSplashScreen):
    def __init__(self):
        Pixmap = QPixmap("src\\start.jpg")
        super(new_splashscreen, self).__init__(Pixmap) # 启动界面加载图片
        self.progressbar = QProgressBar(self)  # 在QSplashScreen上加上进度条
        self.progressbar.setGeometry((Pixmap.width()-500)/2, Pixmap.height()-25, 500, 25)

    def new_showMessage(self):
        for i in range(100):
            # self.showMessage("正在创建触发器... {0}%".format(i), Qt.AlignHCenter | Qt.AlignBottom, Qt.black) # 启动界面展示文字 Qt.AlignHCenter | Qt.AlignBottom 表示在界面的底部中间
            if i <= 30:
                self.showMessage("正在启动界面...".format(i), Qt.AlignLeft | Qt.AlignBottom, Qt.black)
            else:
                self.showMessage("正在创建触发器...".format(i), Qt.AlignLeft | Qt.AlignBottom, Qt.black)
            self.progressbar.setValue(i)
            time.sleep(0.02)

    # def show_progressbar(self):
    #     self.progressbar = QProgressBar(self) # 在QSplashScreen上加上进度条
    #     # self.timer = QBasicTimer()
    #     self.progressbar.setGeometry(30, 40, 200, 25)
    #     # self.timer.start(100, self)
    #     for i in range(100):
    #         self.progressbar.setValue(i)